package com.xujinchen.array;

public class ArrayDemo04 {
    public static void main(String[] args) {
        int[] array = {1, 2, 3, 4, 5};
//        for (int i : array) {
//            System.out.println(i);
//        }
//        printArray(array);
        int[] reserve = reserve(array);
        printArray(reserve);
    }
    //打印数组元素
    public static void printArray(int[] arrays){
        for (int i = 0; i < arrays.length; i++) {
            System.out.print(arrays[i]+" ");
        }
    }
    public static int[] reserve(int[] arrays){
        int[] result =new int[arrays.length];
        for (int i = 0,j=result.length-1; i <=result.length-1; i++,j--) {
//            result[] =arrays[i];
            result[j]=arrays[i];
        }
        return result;

    }
}